package cheme.ProcessEditor.Parts.Streams.Tag;

import org.eclipse.draw2d.Label;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;

import cheme.ProcessEditor.ChemePresentation;
import cheme.ProcessEditor.Figures.DecoratableFigure;
import cheme.ProcessEditor.Figures.TagComponentFig;
import cheme.ProcessEditor.Table.AbstractTableRowPart;
import cheme.ProcessModel.ProcessUnits.Streams.Tags.TagComponent;

public class PartTagComponent extends AbstractTableRowPart
{
	@Override
	protected DecoratableFigure<TagComponentFig> createFigure()
	{
//		BulletedFig<StreamComponentFig> figure = new BulletedFig<StreamComponentFig>(new StreamComponentFig(), new CircularBulletFig());
//		figure.setToolTip(new Label("This is a description for a single component of the overall chemical stream."));
//		return new DecoratableFigure<BulletedFig<StreamComponentFig>>(figure);
		
		TagComponentFig figure = new TagComponentFig();
		figure.setToolTip(new Label("This is a description for a single component of the overall chemical stream."));
		
		return new DecoratableFigure<TagComponentFig>(figure);
	}

	@Override
	protected void createEditPolicies()
	{
		installEditPolicy(EditPolicy.COMPONENT_ROLE, new PolicyTagComponent());
		installEditPolicy(EditPolicy.LAYOUT_ROLE, new PolicyDummyLayout());
	}
	
	public TagComponent getModel()
	{
		return (TagComponent)super.getModel();
	}
	
	public DecoratableFigure<TagComponentFig> getFigure()
	{
		return (DecoratableFigure<TagComponentFig>)super.getFigure();
	}
	
	@Override
	public TagComponentFig getContentPane()
	{
		return getFigure().getContentPane();
	}
	
	@Override
	protected void addChildVisual(EditPart childEditPart, int index)
	{
		if(getModel().isInitial())
		{
			((GraphicalEditPart)childEditPart).getFigure().setForegroundColor(ChemePresentation.Fields.initialForeground);
			((GraphicalEditPart)childEditPart).getFigure().setBackgroundColor(ChemePresentation.Fields.initialBackground);
			((GraphicalEditPart)childEditPart).getFigure().setBorder(ChemePresentation.Fields.initialBorder);
		}
		
		super.addChildVisual(childEditPart, index);
	}
}
